//-------------------------------------------------------------------------
/**
   File:   RegistryValue.h

   Descr.: - todo -

   Author: Stefan Leihkauf
   Date:   8/10/2011
*/
//-------------------------------------------------------------------------
#ifndef _REGISTRYVALUE_H
#define _REGISTRYVALUE_H
#include "registry/RegistryTypes.h"

class RegistryValue
{
	/* instances are created by RegistryKey */
	friend class RegistryKey;

public:
	/* registry value types */
	enum ValueType : unsigned long {
		String 			 = REG_SZ,
		ExpandString	 = REG_EXPAND_SZ,
		Binary 			 = REG_BINARY,
		DWord 			 = REG_DWORD,
		StringList 		 = REG_MULTI_SZ,
		QWord 			 = REG_QWORD,
		Link 			 = REG_LINK,
		None 			 = REG_NONE
	};

	struct ValueData {
		ValueData() : Size(0L), Type(None) { }

		ValueType Type;
		unsigned long Size;
		boost::shared_array<char> Data;
	};

public:
	/// get name
	const StdString& Name() const;
	/// get raw data
	const ValueData& Data() const;
	/// get type of value data
	ValueType ValueKind() const;

	/*	TODO:
		Mir ist hier noch nicht ganz klar, wie die Konvertierung eines Registry-Value-Types (REG_SZ, REG_DWORD, ...)
		in einen POD oder std::string aussehen soll.
	*/

protected:
	/// constructor
	RegistryValue(WinHKey hkey, const StdString& name);

private:
	void UpdateValueData();

private:
	WinHKey _hkey;
	StdString _name;
	ValueData _valueData;
};
#endif //!defined _REGISTRYVALUE_H